#ifndef PM_WORK_REQUEST_H_INCLUDED
#define PM_WORK_REQUEST_H_INCLUDED

#include "pm/dbobject.h"
#include "pm/criteria.h"
#include <wx/datetime.h>

namespace pm
{

class WorkRequest : public db::Object
{
	wxString   m_name;
	double     m_amount;
	wxDateTime m_date;
	int        m_idProject;

public:
	static const wxString TABLE_NAME;
	
public:	
	WorkRequest();
    WorkRequest(wxSQLite3ResultSet& res);
	
	const wxString& name() const { return m_name; }
	void name(const wxString& name) { m_name = name; }
	
	double amount() const { return m_amount; }
	void amount(double a) { m_amount = a; }
	
	const wxDateTime& date() const { return m_date; }
	void date(const wxDateTime& date) { m_date = date; }
	
	int id_project() const { return m_idProject; }
	void id_project(int idProject) { m_idProject = idProject; }

	// DB
	virtual db::update_value_type prepare_insert(wxSQLite3Database& db);
	virtual db::update_value_type prepare_update(wxSQLite3Database& db);
};

/**
 * \class GetWorkRequestsByProject
 */
struct GetWorkRequestsByProject : public ICriteriaForEach<WorkRequest>
{
	int m_idProject;
	
	GetWorkRequestsByProject(int id_project);
	
	virtual wxSQLite3Statement prepare(wxSQLite3Database& db);
};

} // namespace pm

#endif // PM_WORK_REQUEST_H_INCLUDED
